<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../MaterialControlStyles/MaterialDesignTheme.Slider.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <!-- This is the slider style used in the ValueSlider control as well as the GroupSelector Notes: * Only horizontal sliders are currently supported * Doesn't support Ticks -->

  <Style x:Key="DecreaseSliderButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Border Background="Transparent"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="IncreaseSliderButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Border x:Name="Bd" Height="2" Background="{TemplateBinding BorderBrush}"/>
          <!--<ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="Bd" Property="Background" Value="#EEEEEE"/>
            </Trigger>
          </ControlTemplate.Triggers>-->
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="RangeSliderThumbStyleLower" TargetType="{x:Type Thumb}">
    <Setter Property="Template" Value="{StaticResource MaterialDesignSliderThumbLower}"/>
  </Style>

  <Style x:Key="RangeSliderThumbStyleUpper" TargetType="{x:Type Thumb}">
    <Setter Property="Template" Value="{StaticResource MaterialDesignSliderThumbUpper}"/>
  </Style>

  <ControlTemplate x:Key="HorizontalSlider" TargetType="{x:Type Slider}">
    <Grid MinHeight="{TemplateBinding Slider.MinHeight}">
      <Rectangle x:Name="rect" Height="2" Fill="{TemplateBinding BorderBrush}"/>
      <Track Name="PART_Track">
        <Track.DecreaseRepeatButton>
          <RepeatButton Command="Slider.DecreaseLarge" Style="{StaticResource DecreaseSliderButtonStyle}"/>
        </Track.DecreaseRepeatButton>
        <Track.Thumb>
          <Thumb Style="{StaticResource SliderThumbStyle}"/>
        </Track.Thumb>
        <Track.IncreaseRepeatButton>
          <RepeatButton Command="Slider.IncreaseLarge" Style="{StaticResource IncreaseSliderButtonStyle}"/>
        </Track.IncreaseRepeatButton>
      </Track>
    </Grid>
  </ControlTemplate>

  <!-- The background consists of two repeat buttons which are used to change the value of the slider by clicking on the left or right of the thumb. To disable this behavior, we are creating a template for this two repeat buttons, which only contains
  an empty grid. This allows us to click through the overlaying slider and change the value of the second slider. -->
  <ControlTemplate x:Key="RangeSliderRepeatButtonControlTemplate" TargetType="RepeatButton">
    <Grid/>
  </ControlTemplate>

  <ControlTemplate x:Key="RangeSliderTemplateLower" TargetType="Slider">
    <Grid x:Name="Root">
      <Grid x:Name="HorizontalTemplate">
	  	<Rectangle x:Name="PART_RangeSliderMouseCollider" Fill="Transparent"/>
        <Rectangle x:Name="PART_RangeProgressBackground" Height="2" Fill="{TemplateBinding BorderBrush}" Opacity="0.53"/>
        <Rectangle x:Name="PART_RangeProgressBar" Height="2" Fill="{TemplateBinding Foreground}"/>
        <Track x:Name="PART_Track">
          <Track.IncreaseRepeatButton>
            <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Template="{StaticResource RangeSliderRepeatButtonControlTemplate}"/>
          </Track.IncreaseRepeatButton>
          <Track.DecreaseRepeatButton>
            <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Template="{StaticResource RangeSliderRepeatButtonControlTemplate}"/>
          </Track.DecreaseRepeatButton>
          <Track.Thumb>
            <Thumb x:Name="HorizontalThumb" Style="{StaticResource RangeSliderThumbStyleLower}" Foreground="{TemplateBinding Foreground}"/>
          </Track.Thumb>
        </Track>
      </Grid>
    </Grid>
  </ControlTemplate>

  <ControlTemplate x:Key="RangeSliderTemplateUpper" TargetType="Slider">
    <Grid x:Name="Root">
      <Grid x:Name="HorizontalTemplate">
	  	<Rectangle x:Name="PART_RangeSliderMouseCollider" Fill="Transparent"/>
        <Rectangle x:Name="PART_RangeProgressBackground" Height="2" Fill="{TemplateBinding BorderBrush}" Opacity="0.53"/>
        <Rectangle x:Name="PART_RangeProgressBar" Height="2" Fill="{TemplateBinding Foreground}"/>
        <Track x:Name="PART_Track">
          <Track.IncreaseRepeatButton>
            <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Template="{StaticResource RangeSliderRepeatButtonControlTemplate}"/>
          </Track.IncreaseRepeatButton>
          <Track.DecreaseRepeatButton>
            <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Template="{StaticResource RangeSliderRepeatButtonControlTemplate}"/>
          </Track.DecreaseRepeatButton>
          <Track.Thumb>
            <Thumb x:Name="HorizontalThumb" Style="{StaticResource RangeSliderThumbStyleUpper}" Foreground="{TemplateBinding Foreground}"/>
          </Track.Thumb>
        </Track>
      </Grid>
    </Grid>
  </ControlTemplate>

  <Style BasedOn="{StaticResource MaterialDesignAccentSlider}" x:Key="RangeSliderStyleLower" TargetType="Slider">
    <Setter Property="Template" Value="{StaticResource RangeSliderTemplateLower}"/>
  </Style>

  <Style BasedOn="{StaticResource MaterialDesignAccentSlider}" x:Key="RangeSliderStyleUpper" TargetType="Slider">
    <Setter Property="Template" Value="{StaticResource RangeSliderTemplateUpper}"/>
  </Style>

</ResourceDictionary>
